/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.wins.vertx.entity;

import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;

/**
 * Converter for {@link io.wins.vertx.entity.Comment}.
 *
 * NOTE: This class has been automatically generated from the {@link io.wins.vertx.entity.Comment} original class using Vert.x codegen.
 */
public class CommentConverter {

  public static void fromJson(JsonObject json, Comment obj) {
    if (json.getValue("comment") instanceof String) {
      obj.setComment((String)json.getValue("comment"));
    }
    if (json.getValue("concertId") instanceof String) {
      obj.setConcertId((String)json.getValue("concertId"));
    }
    if (json.getValue("createdOn") instanceof String) {
      obj.setCreatedOn((String)json.getValue("createdOn"));
    }
    if (json.getValue("customerId") instanceof String) {
      obj.setCustomerId((String)json.getValue("customerId"));
    }
    if (json.getValue("score") instanceof Number) {
      obj.setScore(((Number)json.getValue("score")).floatValue());
    }
    if (json.getValue("status") instanceof Number) {
      obj.setStatus(((Number)json.getValue("status")).intValue());
    }
  }

  public static void toJson(Comment obj, JsonObject json) {
    if (obj.getComment() != null) {
      json.put("comment", obj.getComment());
    }
    if (obj.getConcertId() != null) {
      json.put("concertId", obj.getConcertId());
    }
    if (obj.getCreatedOn() != null) {
      json.put("createdOn", obj.getCreatedOn());
    }
    if (obj.getCustomerId() != null) {
      json.put("customerId", obj.getCustomerId());
    }
    if (obj.getId() != null) {
      json.put("id", obj.getId());
    }
    json.put("score", obj.getScore());
    json.put("status", obj.getStatus());
  }
}